﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyWindowsService.Entity
{
    //参考资料：https://www.cnblogs.com/youmingkuang/p/10069363.html

    public class BaseViewModel
    {
        /// <summary>
        /// 发送到的页面
        /// </summary>
        public string Mark { set; get; }

        /// <summary>
        /// 备注内容
        /// </summary>
        public string Message { set; get; }
    }

    public class MainViewModel : BaseViewModel
    {
        /// <summary>
        /// 设备参数列表
        /// </summary>
        public List<MainItem> ShebeiItems { set; get; } = new List<MainItem>();

        /// <summary>
        /// 工艺参数列表
        /// </summary>
        public List<MainItem> GongyiItems { set; get; } = new List<MainItem>();

        /// <summary>
        /// 考核参数列表
        /// </summary>
        public List<MainItem> KaoheItems { set; get; } = new List<MainItem>();

        /// <summary>
        /// 其他参数列表
        /// </summary>
        public List<MainItem> QitaItems { set; get; } = new List<MainItem>();

        /// <summary>
        /// 生产进度数据
        /// </summary>
        public ProductionProgressViewModel ProgressView { set; get; } = new ProductionProgressViewModel();
    }

    public class ProductionProgressViewModel
    {
        /// <summary>
        /// 牌号（批次号）
        /// </summary>
        public string BrandName { set; get; }

        /// <summary>
        /// 当日产量
        /// </summary>
        public string DayYield { set; get; }

        /// <summary>
        /// 月累计产量
        /// </summary>
        public string MonthYield { set; get; }

        /// <summary>
        /// 当前批次已完成的重量
        /// </summary>
        public string FinishedWeight { set; get; }

        /// <summary>
        /// 当前批次未完成
        /// </summary>
        public string NoFinishedWeight { set; get; }
    }

    /// <summary>
    /// 展示元素
    /// </summary>
    public class MainItem
    {
        /// <summary>
        /// 参数中文名称
        /// </summary>
        public string Name { set; get; }

        /// <summary>
        /// 参数值
        /// </summary>
        public string Value { set; get; }

        /// <summary>
        /// 单位
        /// </summary>
        public string Unit { set; get; }
    }

    /// <summary>
    /// 生产前检查
    /// </summary>
    public class BeforeCheckModel : BaseViewModel
    {
        public List<BeforeCheckConfigItem> Items = new List<BeforeCheckConfigItem>();
    }

    public class BeforeCheckConfigItem
    {
        /// <summary>
        /// 参数编码
        /// </summary>
        public string KeyCode { set; get; }

        /// <summary>
        /// 参数中文名
        /// </summary>
        public string Title { set; get; }

        /// <summary>
        /// 参数实际值
        /// </summary>
        public string Value { set; get; }

        /// <summary>
        /// 设备状态：正常、偏高、偏低、异常
        /// </summary>
        public string ShebeiStatus
        {
            get
            {
                var str = "正常";
                double.TryParse(this.Value, out var v);
                if (v < StandardMinValue)
                    str = "异常";
                if (v > StandardMaxValue)
                    str = "偏高";
                return str;
            }
        }

        /// <summary>
        /// 设备最大值
        /// </summary>
        public string ShebeiMaxValue { set; get; }

        /// <summary>
        /// 正常最小值
        /// </summary>
        public double StandardMinValue { set; get; }

        /// <summary>
        /// 正常最大值
        /// </summary>
        public double StandardMaxValue { set; get; }

        /// <summary>
        /// 单位
        /// </summary>
        public string Unit { set; get; }
    }
}
